﻿using System;
using System.Collections;
using System.Collections.Generic;
using com.guojin.mj.net.message.login;
using UnityEngine;
using UnityEngine.UI;

public class ShopPanel : EventManager {
    public Button Ret,Copy,ChageMoney;
    public Text cp;
    private int Type=1;//1为钻石2金币
    public override void InformationSetting()
    {
        Copy.onClick.AddListener(Cp);
    }
    void Start () {
        Ret.onClick.AddListener(delegate {
            Destroy(this.gameObject);
        });
        if (Type==2)
        {
            ChageMoney.gameObject.SetActive(false);
        }
        ChageMoney.onClick.AddListener(ShowMoney);
    }
    public void Set(int type) {
        Type = type;
    }
    void Cp() {
        LoginAndShare.Controller.callAndroidJava("copyTextToClipboard", cp.text);
        TooL.WenXinTiSi("恭喜您复制成功！");
    }
    public void SendMoney60() {
        Debug.Log("60");
        SHWXPay wxp = SHWXPay.Create(1, 0);
        SocketMgr.GetInstance().Send(com.guojin.mj.net.Net.instance.write(wxp));
    }
    public void SendMoney300()
    {
        Debug.Log("300");
        SHWXPay wxp = SHWXPay.Create(2, 0);
        SocketMgr.GetInstance().Send(com.guojin.mj.net.Net.instance.write(wxp));
    }
    public void SendMoney1280()
    {
        Debug.Log("1280");
        SHWXPay wxp = SHWXPay.Create(3, 0);
        SocketMgr.GetInstance().Send(com.guojin.mj.net.Net.instance.write(wxp));
    }
    public void SendMoney3280()
    {
        Debug.Log("3280");
        SHWXPay wxp = SHWXPay.Create(4, 0);
        SocketMgr.GetInstance().Send(com.guojin.mj.net.Net.instance.write(wxp));
    }
    public void SendMoney6280()
    {
        Debug.Log("6280");
        SHWXPay wxp = SHWXPay.Create(5, 0);
        SocketMgr.GetInstance().Send(com.guojin.mj.net.Net.instance.write(wxp));
    }
    public void ChangeMoney60()
    {
        TooL.ShowTipsPage(string.Format("是否确认兑换60钻石？"), TooL.TipsPageType.haveCancelPage,
             () => { MessageManager.GetInstance().Send7163(60); },
             () => { CloseBtnClick(); }
             );
    }
    public void ChangeMoney300()
    {
        TooL.ShowTipsPage(string.Format("是否确认兑换300钻石？"), TooL.TipsPageType.haveCancelPage,
            () => { MessageManager.GetInstance().Send7163(300); },
            () => { CloseBtnClick(); }
            );
    }
    public void ChangeMoney1280()
    {
        TooL.ShowTipsPage(string.Format("是否确认兑换1280钻石？"), TooL.TipsPageType.haveCancelPage,
               () => { MessageManager.GetInstance().Send7163(1280); },
               () => { CloseBtnClick(); }
               );
    }

    public void ChangeMoney3280()
    {
        TooL.ShowTipsPage(string.Format("是否确认兑换3280钻石？"), TooL.TipsPageType.haveCancelPage,
             () => { MessageManager.GetInstance().Send7163(3280); },
             () => { CloseBtnClick(); }
             );
    }

    public void ChangeMoney6280()
    {
        TooL.ShowTipsPage(string.Format("是否确认兑换6180钻石？"), TooL.TipsPageType.haveCancelPage,
            () => { MessageManager.GetInstance().Send7163(6180); },
            () => { CloseBtnClick(); }
            );
    }
    void ShowMoney()
    {
        UIManager.ChangeUI(UIManager.PageState.ChangeMoney, (GameObject obj) =>
        {
            obj.GetComponent<ShopPanel>().InformationSetting();
            obj.GetComponent<ShopPanel>().Set(2);
        });
    }
}
